package io.itit.ecp.admin.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.EnergyConsumptionTypeEntity;
import io.itit.ecp.admin.server.mapper.EnergyConsumptionTypeMapper;
import io.itit.ecp.admin.server.service.IEnergyConsumptionTypeService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EnergyConsumptionTypeServiceImpl extends JoinServiceImpl<EnergyConsumptionTypeMapper, EnergyConsumptionTypeEntity>
        implements IEnergyConsumptionTypeService {

    @Override
    public String getElectricId() {
        return getOne(new LambdaQueryWrapper<EnergyConsumptionTypeEntity>()
                .eq(EnergyConsumptionTypeEntity::getEnergyName, "电")).getId();
    }

    @Override
    public String getWaterId() {
        return getOne(new LambdaQueryWrapper<EnergyConsumptionTypeEntity>()
                .eq(EnergyConsumptionTypeEntity::getEnergyName, "水")).getId();
    }

    @Override
    public String getColdId() {
        return getOne(new LambdaQueryWrapper<EnergyConsumptionTypeEntity>()
                .eq(EnergyConsumptionTypeEntity::getEnergyName, "冷")).getId();
    }

    @Override
    public List<EnergyConsumptionTypeEntity> findByEnergyCategoryId(String energyCategoryId) {
        return lambdaQuery()
                .eq(EnergyConsumptionTypeEntity::getEnergyCategory, energyCategoryId)
                .eq(EnergyConsumptionTypeEntity::getStatus, "1")
                .list();
    }
}
